package cuongnh.project.japanesediary.vocabulary.ui.editor.text.page.general;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.editor.FormPage;
import org.eclipse.ui.forms.widgets.Section;

import cuongnh.project.japanesediary.vocabulary.common.CommonServices;
import cuongnh.project.japanesediary.vocabulary.model.Text;
import cuongnh.project.japanesediary.vocabulary.ui.editor.text.page.general.section.TextGeneralInfoSection;

public class TextGeneralInfoPage extends FormPage {

	private static Log m_Log = LogFactory
			.getLog(TextGeneralInfoPage.class);

	private Text text;

	private CommonServices commonServices;

	public TextGeneralInfoPage(FormEditor editor, Text text,
			CommonServices commonServices, String id, String title) {
		super(editor, id, title);
		this.text = text;
		this.commonServices = commonServices;
	}

	/**
	 * Create contents of the form.
	 * 
	 * @param managedForm
	 */
	@Override
	protected void createFormContent(IManagedForm managedForm) {
		managedForm.getForm().getBody().setLayout(new GridLayout(1, false));
		TextGeneralInfoSection textGeneralInfoSection = new TextGeneralInfoSection(
				managedForm.getForm().getBody(), text, commonServices,
				managedForm.getToolkit(), Section.EXPANDED | Section.TITLE_BAR);
		textGeneralInfoSection.getSection().setLayoutData(
				new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		managedForm.addPart(textGeneralInfoSection);
	}

	@Override
	public void doSave(IProgressMonitor monitor) {
		m_Log.debug("Saving from TextGeneralInfoPage!");
		super.doSave(monitor);
	}

}
